home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / BF_SDK11.ZIP / BFE_ASM.INC < prev    next >
Text File  |  1996-06-03  |  3KB  |  107 lines

  1.  
  2.  
  3. ; Include file to use the Blowfish-Engine BFENG386 from Assembler
  4. ; (c) 1996 Cedric Reinartz
  5.  
  6. ; !!!       All restrictions in BF-SDK.TXT apply        !!!
  7.  
  8. ; The variable noPUB decides if the sourcecode from BFENG386 will be
  9. ; included, or if the Objekt-File BFENG386.OBJ will be used.
  10.  
  11. ifndef noPUB
  12.         extrn Blowfish_GetBoxPointer: far
  13.         extrn Blowfish_GetBoxes: far
  14.         extrn Blowfish_SetBoxes: far
  15.         extrn Blowfish_Init: far
  16.         extrn Blowfish_ECBEncrypt: far
  17.         extrn Blowfish_ECBDecrypt: far
  18.         extrn Blowfish_CBCEncrypt: far
  19.         extrn Blowfish_CBCDecrypt: far
  20.         extrn Blowfish_Done: far
  21.         extrn Blowfish_SetRounds: far
  22.     extrn Blowfish_WeakKey: far
  23.     .model large
  24.     .386
  25. else
  26.     include bfeng386.asm
  27. endif
  28.  
  29.  
  30. callf    macro p1
  31. ;    call    far ptr p1        ; normaly you don't need it
  32.     call    p1            ; The Ass. detects it from .model 
  33. endm
  34.  
  35. _GetBoxPointer macro            ; returns a Pointer to PBox
  36.     callf    Blowfish_GetBoxPointer    ; (DX:AX)
  37. endm
  38.  
  39. _GetBoxes macro seg,off            ; Saves the aktual P- and SBoxes
  40.     push    seg            ; at adress  seg:off
  41.     push    off
  42.     callf    Blowfish_GetBoxes
  43. endm
  44.  
  45. _SetBoxes macro seg,off            ; loads the P- and SBoxes with Data
  46.     push    seg            ; from adress   seg:off
  47.     push    off
  48.     callf    Blowfish_SetBoxes
  49. endm
  50.  
  51. _ClearBoxes macro            ; Wipes all Boxes clear
  52.     callf    Blowfish_Done
  53. endm
  54.  
  55. _SetRounds macro rnds            ; Set the number of Rounds
  56.     push    rnds
  57.     callf    Blowfish_SetRounds
  58. endm
  59.  
  60. _InitCrypt macro seg,off,len        ; Initialises the Key with the Passw.
  61.     push    seg
  62.     push    off
  63.     push    len
  64.     callf    Blowfish_Init
  65. endm
  66.  
  67. _WeakKey macro
  68.     callf    Blowfish_WeakKey    ; Test if (initialised) Key is weak
  69. endm
  70.  
  71. _Encrypt macro seg,off,len        ; Encrypts a String (ECB Method)
  72.     push    seg            ; len must be x*8
  73.     push    off            
  74.     push    len
  75.     callf    Blowfish_ECBEncrypt
  76. endm
  77.  
  78. _Decrypt macro seg,off,len        ; Decrypts a String (ECB Method)
  79.     push    seg            ; len must be x*8
  80.     push    off        
  81.     push    len
  82.     callf    Blowfish_ECBDecrypt
  83. endm
  84.  
  85. _CBCEncrypt macro seg,off,len,segcl,offcl,segch,offch  ; encrypts (CBC Method)
  86.     push    seg        ; Adress of the Data
  87.     push    off
  88.     push    len        ; len of data
  89.     push    segcl        ; Adress of CBC low
  90.     push    offcl
  91.     push    segch        ; and CBC high
  92.     push    offch
  93.     callf    Blowfish_CBCEncrypt
  94. endm
  95.  
  96. _CBCDecrypt macro seg,off,len,segcl,offcl,segch,offch ; decrypts (CBC Method)
  97.     push    seg        ; Adress of the Data
  98.     push    off
  99.     push    len        ; and their length 
  100.     push    segcl        ; Adresse of CBC low
  101.     push    offcl
  102.     push    segch        ; and CBC high
  103.     push    offch
  104.     callf    Blowfish_CBCDecrypt
  105. endm
  106.  
  107.